<template>
  <div class="property">
    <div class="property-title">资产总额</div>
    <div class="property-value">
      <div v-for="(item, index) in moneyCount" :key="index" class="property-value-item">
        {{ item }}
      </div>
      <div class="property-unit">
        {{ unit }}
      </div>
    </div>
  </div>
</template>
<script>
import { animateNumber } from "@/utils/common";
export default {
  name: "property-srceen",
  props: {
    total: {
      type: Number,
      default: 0,
    },
  },
  data() {
    return {
      moneyCount: 0,
      unit: "",
    };
  },
  watch: {
    total() {
      this.getCount();
    },
  },
  mounted() {
    this.getCount();
  },
  methods: {
    getCount() {
      let max = this.total;
      if (max > 100000000) {
        max = Math.round(max / 10000);
        this.unit = "万元";
      } else {
        this.unit = "元";
      }
      let params = {
        end: max,
        covering: 9,
      };
      animateNumber(params, (value) => {
        this.moneyCount = value.split("");
        this.$forceUpdate();
      });
    },
  },
};
</script>
<style lang="scss" scoped>
.property {
  width: 100%;
  display: flex;
  align-items: center;
  margin-top: 23px;
  &-title {
    font-family: SHUHETI-bold;
    font-weight: 400;
    font-size: 20px;
    color: #ffffff;
    margin: 0 15px;
  }
  &-value {
    font-weight: bold;
    font-size: 65px;
    color: #03eeff;
    position: relative;
    display: flex;
    &-item {
      font-family: DS-DIGIB;
      margin-right: 5px;
      background: url("~@/assets/num-bg.png") no-repeat;
      width: 65px;
      height: 85px;
      background-size: 100% 100%;
      display: flex;
      align-items: center;
      justify-content: center;
    }
  }
  &-unit {
    font-family: SHUHETI-bold;
    position: absolute;
    bottom: 0;
    right: -40px;
    font-size: 20px;
    color: #ffffff;
  }
}
</style>
